home *** CD-ROM | disk | FTP | other *** search
Text File | 1998-06-12 | 1.2 KB | 77 lines | [TEXT/CWIE] |
- #include "InspectorTest.h"
- #include "SmartPtr.h"
-
- DefineClass1Base(ClassA, TObject);
- DefineClass1Base(ClassB, ClassA);
- DefineClass2Base(ClassC, ClassA, TObject);
- DefineClass2Base(ClassD, ClassB, ClassC);
-
- static SmartPtr<ClassA> foo(ClassA& a)
- {
- a.fVariableA = 7;
-
- return &a;
- }
-
- class Foo
- {
- public:
-
- static ObjectPtr TestFunc(TObject& foo)
- {
- return &foo; // try to set a breakpoint here....
- }
-
- };
-
- static void unexpected_called()
- {
- DebugStr("\pSomeone called unexpected() - you're hosed.");
- }
-
- static void terminate_called()
- {
- DebugStr("\pSomeone called terminate() - you're hosed.");
- }
-
- void InspectorTest(void)
- {
- Debugger();
-
- try
- {
- ObjectPtr o(new ClassA(7));
- SmartPtr<ClassC> c(new ClassC(9));
- SmartPtr<ClassB> b(new ClassD(11,22,33));
- SmartPtr<ClassD> d(new ClassD(11,22,33));
-
- SmartPtr<TObjectList> list = new TObjectList;
-
- o = Foo::TestFunc(*o);
-
- list->AppendObject(o);
- list->AppendObject(b);
-
- {
- SmartPtr<ClassA> a = foo(*c);
-
- list->AppendObject(a);
-
- Debugger();
- }
-
- list->AppendObject(d);
-
- Debugger();
-
- FailOSErr(69); // <-- step over to hose CW
- }
- catch(...)
- {
- DebugStr("\pException caught");
- }
-
- Debugger();
- }
-
-